package com.etone.smartAudit.dto.task;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 蒋学伟
 * @create: 2020-06-30 11:17:57
 * @Description WorkTaskDTO
 */
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
@ApiModel(value = "WorkTaskDTO", description = "工作任务")
public class WorkTaskDTO implements Serializable {

    @ApiModelProperty("任务名称")
    @NotEmpty
    private String name;

    @ApiModelProperty("工具中台")
    private ToolWorkTaskDTO toolTask;

    @ApiModelProperty("服务中台")
    private ServiceExpertWorkTaskDTO serviceExpertTask;

    @ApiModelProperty("服资源调度中台")
    private ItemSourceWorkTaskDTO itemSourceTask;

    @ApiModelProperty("数据中台")
    private DataWorkTaskDTO dataTask;

    @JsonIgnore
    public List<BaseTaskDTO> getBaseTasks() {
        List<BaseTaskDTO> taskDTOS = new ArrayList<>();
        if (toolTask != null) {
            taskDTOS.add(toolTask);
        }
        if (serviceExpertTask != null) {
            taskDTOS.add(serviceExpertTask);
        }
        if (itemSourceTask != null) {
            taskDTOS.add(itemSourceTask);
        }
        if (dataTask != null) {
            taskDTOS.add(dataTask);
        }
        return taskDTOS;
    }

}
